1. Field of the Invention
The present invention relates to computer systems. More particularly, the present invention relates to language subset validation.
2. Background
Object oriented programming techniques such as those used by the Java(trademark) platform are widely used. The basic unit of object oriented programs is the object which has methods (procedures) and fields (data), herein called members. Objects that share members are grouped into classes. A class defines the shared members of the objects in the class. Each object then is a particular instance of the class to which it belongs. In practice, a class is often used as a template to create multiple objects (multiple instances) with similar features.
One property of classes is encapsulation, which describes the property that the actual implementation of the members within the class is hidden from an outside user, and other classes, except as exposed by an interface. This makes classes suitable for distributed development, for example by different developers at different sites on a network. A complete program can be formed by assembling the classes that are needed, linking them together, and executing the resulting program.
Classes enjoy the property of inheritance. Inheritance is a mechanism that enables one class to inherit all of the members of another class. The class that inherits from another class is called a subclass; the class that provides the attributes is the superclass. Symbolically, this can be written as subclass  less than =superclass, or superclass= greater than  subclass. The subclass can extend the capabilities of the superclass by adding additional members. The subclass can override a virtual method of the superclass by providing a substitute method with the same name and type.
The members of a class type are fields and methods; these include members inherited from the superclass. The class file also names the superclass. A member can be public, which means that it can be accessed by members of the class that contains its declaration. A member can also be private. A private field of a class is visible only in methods defined within that class. Similarly, a private method may only be invoked by methods within the class. Private members are not visible within subclasses, and are not inherited by subclasses as other members are. A member can also be protected.
An interface type is a type whose members are constants and abstract methods. This type has no implementation, but otherwise unrelated classes can implement it by providing implementations for its abstract methods. Interfaces may have sub-interfaces, just as classes may have subclasses. A sub-interface inherits from its super-interface, and may define new methods and constants as well. Additionally, an interface can extend more than one interface at a time. An interface that extends more than one interface inherits all the abstract methods and constants from each of those interfaces, and may define its own additional methods and constants.
In the Java(trademark) programming language, classes can be grouped and the group can be named; the named group of classes is a package. If a class member is not declared with any of the public, private or protected keywords, then it is visible only within the class that defines it and within classes that are part of the same package. A protected member may be accessed by members of declaring class or from anywhere in the package in which it is declared. The Java(trademark) programming language is described in detail in Gosling, et al., xe2x80x9cThe Java(trademark) Language Specificationxe2x80x9d, August 1996, Addison-Wesley Longman, Inc.
A virtual machine is an abstract computing machine generated by a software application or sequence of instructions that is executed by a processor. The term xe2x80x9carchitecture-neutralxe2x80x9d refers to programs, such as those written in the Java(trademark) programming language, which can be executed by a virtual machine on a variety of computer platforms having a variety of different computer architectures. Thus, for example, a virtual machine implemented on a Windows(trademark)-based personal computer system will execute an application using the same set of instructions as a virtual machine implemented on a UNIX(trademark)-based computer system. The result of the platform-independent coding of a virtual machine""s sequence of instructions is a stream of one or more bytecodes, each of which is, for example, a one-byte-long numerical code.
The Java(trademark) Virtual Machine is one example of a virtual machine. Compiled code to be executed by the Java(trademark) Virtual Machine is represented using a hardware- and operating system-independent binary format, typically stored in a file, known as the class file format. The class file is designed to handle object oriented structures that can represent programs written in the Java(trademark) programming language, but may also support several other programming languages. The class file format precisely defines the representation of a class or interface, including details such as byte ordering that might be taken for granted in a platform-specific object file format. For the sake of security, the Java(trademark) Virtual Machine imposes strong format and structural constraints on the instructions in a class file. Any language with functionality that can be expressed in terms of a valid class file can be hosted by the Java(trademark) Virtual Machine. The class file is designed to handle object oriented structures that can represent programs written in the Java(trademark) programming language, but may also support several other programming languages. The Java(trademark) Virtual Machine is described in detail in Lindholm, et al., xe2x80x9cThe Java(trademark) Virtual Machine Specificationxe2x80x9d, April 1999, Addison-Wesley Longman, Inc., Second Edition.
Resource-constrained devices are generally considered to be those that are relatively restricted in memory and/or computing power or speed, as compared to typical desktop computers and the like. Other resource-constrained devices include, by way of example, cellular telephones, boundary scan devices, field programmable devices, personal digital assistants (PDAs) and pagers and other miniature or small footprint devices. The invention can also be used on non-resource constrained devices.
For the purposes of this disclosure, the term xe2x80x9cprocessorxe2x80x9d may be used to refer to a physical computer or a virtual machine.
Smart cards, also known as intelligent portable data-carrying cards, are a type of resource-constrained device. Smart cards are made of plastic or metal and have an electronic chip that includes an embedded microprocessor or microcontroller to execute programs and memory to store programs and data. Such devices, which can be about the size of a credit card, have computer chips with 8-bit or 16-bit architectures. Additionally, these devices typically have limited memory capacity. For example, some smart cards have less than one kilo-byte (1K) of random access memory (RAM) as well as limited read only memory (ROM), and/or non-volatile memory such as electrically erasable programmable read only memory (EEPROM).
A Java(trademark) virtual machine executes programs written in the Java(trademark) programming language and is designed for use on desktop computers, which are relatively rich in memory. It would be desirable to write programs that use the full implementation of the Java(trademark) Virtual Machine for execution on resource constrained devices such as smart cards. However, due to the limited architecture and memory of resource-constrained devices such as smart cards, the full Java(trademark) Virtual Machine platform cannot be implemented on such devices. Accordingly, a separate Java Card(trademark) (the smart card that supports the Java(trademark) programming language) technology supports a subset of the Java(trademark) programming language for resource-constrained devices.
Some items supported in Java(trademark) technology are not supported in Java Card(trademark) technology. For example, Java(trademark) technology supports types char, double, float and long, but Java Card(trademark) technology does not. Additionally, some Java(trademark) language features are supported in a limited fashion., Java Card(trademark) technology limits the range of operations of these features to less than that of the Java(trademark) technology. For example, Java(trademark) technology allows arrays having more than one dimension, while the Java Card(trademark) technology allows arrays having only one dimension.
In Java Card(trademark) technology, a Java Card(trademark) converter takes regular class files as input and converts them to a CAP (converted applet) file. The CAP format supports a subset of the class file information. Each CAP file contains all of the classes and interfaces defined in one Java(trademark) package. A CAP file has a compact and optimized format, so that a Java(trademark) package can be efficiently stored and executed on resource-constrained devices. After conversion, the CAP file is installed on the Java Card(trademark) technology enabled device.
The existence of a subset of the Java(trademark) language for Java Card(trademark) technology means that valid Java(trademark) program modules including items not supported by the Java Card(trademark) subset may be created. Execution of these program modules on resource-constrained devices may produce erroneous results. Accordingly, a need exists in the prior art for a method and apparatus for language subset validation that facilitates correct execution of applications on resource-constrained devices.
A method for language subset validation includes validating multiple program modules that comprise a program. Each of the program modules includes multiple bytecodes defined for a first computer language that is a hardware-dependent subset of a second computer language. The validation includes indicating an error condition for each item in the multiple program modules that is not defined for the first computer language, indicating an error condition for each item in the multiple program modules that is not supported by an execution environment of the first computer language and indicating an error condition for each item in the plurality of program modules that is defined for the first computer language but used in a manner inconsistent with the first computer language. An apparatus for language subset validation includes at least one memory having program instructions and at least one processor configured to use the program instructions to validate multiple program modules that together form a program. The processor is further configured to use the program instructions to indicate an error condition for each item in the multiple program modules that is not defined for the first computer language, indicate an error condition for each item in the multiple program modules that is not supported by an execution environment of the first computer language and indicate an error condition for each item in the plurality of program modules that is defined for the first computer language but used in a manner inconsistent with the first computer language.